'use strict';

let response = function(code, data, msg) {
	return {
		code: code,
		data: data,
		msg: msg || '成功'
	}
}
const db = uniCloud.database();
exports.main = async (event, context) => {
	console.log(event, '——————拿到的参数')
	if (!event.collectionName)
		return response(60000, undefined, '参数错误')
	let collection = await db.collection(event.collectionName);
	if (!db)
		return response(60000, undefined, '数据库不存在')
	let res = await collection.add(event.data) // 单条数据插入
	return response(10000, res)
};
